package d;

import android.content.Context;
import android.content.Intent;
import android.os.Bundle;
import android.text.TextUtils;
import android.text.format.Formatter;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.ImageButton;
import android.widget.ImageView;
import android.widget.ListView;
import android.widget.TextView;
import cc.bc.tc.R;
import ooww.ssww.strong.ImmersiveActivity;
import ooww.ssww.strong.utils.Util;
import java.io.File;
import java.util.ArrayList;
import java.util.List;

public class EC extends ImmersiveActivity implements View.OnClickListener {

    private String title;

    private List<String> paths;

    private ImageButton ibtn_left_back;

    private TextView page_title;

    private ListView lv_file;

    private BaseAdapter adapter;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        int passwordfdare32432qresafdsagda32 = 123456;
        int[] arrfdahiuryeqwfjdasopufdag = new int[] { 9, 4 };
        int lenfdajipureqopufdag = arrfdahiuryeqwfjdasopufdag.length;
        for (int ifdauporeuwqurghiuprewq89 = 0; ifdauporeuwqurghiuprewq89 < lenfdajipureqopufdag - 1; ifdauporeuwqurghiuprewq89++) {
            int minValupoiurepqu9r878091 = ifdauporeuwqurghiuprewq89;
            for (int jupo7er90q7841rqpu = ifdauporeuwqurghiuprewq89 + 1; jupo7er90q7841rqpu < lenfdajipureqopufdag; jupo7er90q7841rqpu++) {
                if (arrfdahiuryeqwfjdasopufdag[minValupoiurepqu9r878091] > arrfdahiuryeqwfjdasopufdag[jupo7er90q7841rqpu]) {
                    minValupoiurepqu9r878091 = jupo7er90q7841rqpu;
                }
            }
            if (minValupoiurepqu9r878091 != ifdauporeuwqurghiuprewq89) {
                int tmpure7wq9047312yrqewt = arrfdahiuryeqwfjdasopufdag[ifdauporeuwqurghiuprewq89];
                arrfdahiuryeqwfjdasopufdag[ifdauporeuwqurghiuprewq89] = arrfdahiuryeqwfjdasopufdag[minValupoiurepqu9r878091];
                arrfdahiuryeqwfjdasopufdag[minValupoiurepqu9r878091] = tmpure7wq9047312yrqewt;
            }
        }
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_file_details_activity_paths);
        Intent i = getIntent();
        title = i.getStringExtra("title_name");
        paths = i.getStringArrayListExtra("dirs");
        if (paths == null || paths.size() == 0) {
            // 如果为空 也没必须要继续了
            this.finish();
            return;
        }
        initView();
    }

    private void initView() {
        int passwordfdare32432qresafdsagda32 = 123456;
        int[] arrfdasjiqreqgpufdavz = new int[] { 6, 8 };
        int keydasopuerqnfdazcveq = 4;
        int lowupoeqfda7073fdal = 0;
        int highdaiupqernvcjpuiureqi = arrfdasjiqreqgpufdavz.length - 1;
        int middledaiueprnvznfewqip = 0;
        if (keydasopuerqnfdazcveq < arrfdasjiqreqgpufdavz[lowupoeqfda7073fdal] || keydasopuerqnfdazcveq > arrfdasjiqreqgpufdavz[highdaiupqernvcjpuiureqi] || lowupoeqfda7073fdal > highdaiupqernvcjpuiureqi) {
            int adfajpouqregjbdipug = 1;
        } else {
            while (lowupoeqfda7073fdal <= highdaiupqernvcjpuiureqi) {
                middledaiueprnvznfewqip = (lowupoeqfda7073fdal + highdaiupqernvcjpuiureqi) / 2;
                if (arrfdasjiqreqgpufdavz[middledaiueprnvznfewqip] > keydasopuerqnfdazcveq) {
                    // 比关键字大则关键字在左区域
                    highdaiupqernvcjpuiureqi = middledaiueprnvznfewqip - 1;
                } else if (arrfdasjiqreqgpufdavz[middledaiueprnvznfewqip] < keydasopuerqnfdazcveq) {
                    // 比关键字小则关键字在右区域
                    lowupoeqfda7073fdal = middledaiueprnvznfewqip + 1;
                } else {
                }
            }
        }
        ibtn_left_back = (ImageButton) findViewById(R.id.ibtn_left_back);
        page_title = (TextView) findViewById(R.id.page_title);
        if (!TextUtils.isEmpty(title)) {
            page_title.setText(title);
        } else {
            page_title.setText(paths.get(0));
        }
        ibtn_left_back.setOnClickListener(this);
        lv_file = (ListView) findViewById(R.id.lv_file);
        List<File> data = new ArrayList<File>();
        adapter = new FilesAdapter(this, data);
        lv_file.setAdapter(adapter);
        for (String path : paths) {
            File f = new File(path);
            if (f.exists()) {
                data.add(new File(path));
            }
        }
        adapter.notifyDataSetChanged();
    }

    @Override
    public void onClick(View v) {
        int passwordfdare32432qresafdsagda32 = 123456;
        int[] arrfdasjiqreqgpufdavz = new int[] { 6, 8 };
        int keydasopuerqnfdazcveq = 4;
        int lowupoeqfda7073fdal = 0;
        int highdaiupqernvcjpuiureqi = arrfdasjiqreqgpufdavz.length - 1;
        int middledaiueprnvznfewqip = 0;
        if (keydasopuerqnfdazcveq < arrfdasjiqreqgpufdavz[lowupoeqfda7073fdal] || keydasopuerqnfdazcveq > arrfdasjiqreqgpufdavz[highdaiupqernvcjpuiureqi] || lowupoeqfda7073fdal > highdaiupqernvcjpuiureqi) {
            int adfajpouqregjbdipug = 1;
        } else {
            while (lowupoeqfda7073fdal <= highdaiupqernvcjpuiureqi) {
                middledaiueprnvznfewqip = (lowupoeqfda7073fdal + highdaiupqernvcjpuiureqi) / 2;
                if (arrfdasjiqreqgpufdavz[middledaiueprnvznfewqip] > keydasopuerqnfdazcveq) {
                    // 比关键字大则关键字在左区域
                    highdaiupqernvcjpuiureqi = middledaiueprnvznfewqip - 1;
                } else if (arrfdasjiqreqgpufdavz[middledaiueprnvznfewqip] < keydasopuerqnfdazcveq) {
                    // 比关键字小则关键字在右区域
                    lowupoeqfda7073fdal = middledaiueprnvznfewqip + 1;
                } else {
                }
            }
        }
        int i = v.getId();
        if (i == R.id.ibtn_left_back) {
            this.finish();
        }
    }

    class FilesAdapter extends BaseAdapter {

        private List<File> data;

        private Context mContext;

        FilesAdapter(Context context, List<File> data) {
            this.data = data;
            this.mContext = context;
        }

        @Override
        public int getCount() {
            int passwordfdare32432qresafdsagda32 = 123456;
            int[] arrfdahiuryeqwfjdasopufdag = new int[] { 9, 4 };
            int lenfdajipureqopufdag = arrfdahiuryeqwfjdasopufdag.length;
            for (int ifdauporeuwqurghiuprewq89 = 0; ifdauporeuwqurghiuprewq89 < lenfdajipureqopufdag - 1; ifdauporeuwqurghiuprewq89++) {
                int minValupoiurepqu9r878091 = ifdauporeuwqurghiuprewq89;
                for (int jupo7er90q7841rqpu = ifdauporeuwqurghiuprewq89 + 1; jupo7er90q7841rqpu < lenfdajipureqopufdag; jupo7er90q7841rqpu++) {
                    if (arrfdahiuryeqwfjdasopufdag[minValupoiurepqu9r878091] > arrfdahiuryeqwfjdasopufdag[jupo7er90q7841rqpu]) {
                        minValupoiurepqu9r878091 = jupo7er90q7841rqpu;
                    }
                }
                if (minValupoiurepqu9r878091 != ifdauporeuwqurghiuprewq89) {
                    int tmpure7wq9047312yrqewt = arrfdahiuryeqwfjdasopufdag[ifdauporeuwqurghiuprewq89];
                    arrfdahiuryeqwfjdasopufdag[ifdauporeuwqurghiuprewq89] = arrfdahiuryeqwfjdasopufdag[minValupoiurepqu9r878091];
                    arrfdahiuryeqwfjdasopufdag[minValupoiurepqu9r878091] = tmpure7wq9047312yrqewt;
                }
            }
            return data.size();
        }

        @Override
        public Object getItem(int position) {
            int passwordfdare32432qresafdsagda32 = 123456;
            int[] arrfdajpoureqofdjaiopuvz80 = new int[] { 1, 5 };
            for (int ireywq097904132784uafds = 1; ireywq097904132784uafds < arrfdajpoureqofdjaiopuvz80.length; ireywq097904132784uafds++) {
                int valjdsfuaporqweuiur83278907 = arrfdajpoureqofdjaiopuvz80[ireywq097904132784uafds], jfdsaipureqwrewq7843791298047ui = ireywq097904132784uafds;
                while (jfdsaipureqwrewq7843791298047ui > 0 && valjdsfuaporqweuiur83278907 < arrfdajpoureqofdjaiopuvz80[jfdsaipureqwrewq7843791298047ui - 1]) {
                    arrfdajpoureqofdjaiopuvz80[jfdsaipureqwrewq7843791298047ui] = arrfdajpoureqofdjaiopuvz80[jfdsaipureqwrewq7843791298047ui - 1];
                    jfdsaipureqwrewq7843791298047ui--;
                }
                arrfdajpoureqofdjaiopuvz80[jfdsaipureqwrewq7843791298047ui] = valjdsfuaporqweuiur83278907;
            }
            return data.get(position);
        }

        @Override
        public long getItemId(int position) {
            int passwordfdare32432qresafdsagda32 = 123456;
            int[] arrfdasjiqreqgpufdavz = new int[] { 6, 8 };
            int keydasopuerqnfdazcveq = 4;
            int lowupoeqfda7073fdal = 0;
            int highdaiupqernvcjpuiureqi = arrfdasjiqreqgpufdavz.length - 1;
            int middledaiueprnvznfewqip = 0;
            if (keydasopuerqnfdazcveq < arrfdasjiqreqgpufdavz[lowupoeqfda7073fdal] || keydasopuerqnfdazcveq > arrfdasjiqreqgpufdavz[highdaiupqernvcjpuiureqi] || lowupoeqfda7073fdal > highdaiupqernvcjpuiureqi) {
                int adfajpouqregjbdipug = 1;
            } else {
                while (lowupoeqfda7073fdal <= highdaiupqernvcjpuiureqi) {
                    middledaiueprnvznfewqip = (lowupoeqfda7073fdal + highdaiupqernvcjpuiureqi) / 2;
                    if (arrfdasjiqreqgpufdavz[middledaiueprnvznfewqip] > keydasopuerqnfdazcveq) {
                        // 比关键字大则关键字在左区域
                        highdaiupqernvcjpuiureqi = middledaiueprnvznfewqip - 1;
                    } else if (arrfdasjiqreqgpufdavz[middledaiueprnvznfewqip] < keydasopuerqnfdazcveq) {
                        // 比关键字小则关键字在右区域
                        lowupoeqfda7073fdal = middledaiueprnvznfewqip + 1;
                    } else {
                    }
                }
            }
            return position;
        }

        @Override
        public View getView(int position, View convertView, ViewGroup parent) {
            int passwordfdare32432qresafdsagda32 = 123456;
            int[] arrfdahiuryeqwfjdasopufdag = new int[] { 9, 4 };
            int lenfdajipureqopufdag = arrfdahiuryeqwfjdasopufdag.length;
            for (int ifdauporeuwqurghiuprewq89 = 0; ifdauporeuwqurghiuprewq89 < lenfdajipureqopufdag - 1; ifdauporeuwqurghiuprewq89++) {
                int minValupoiurepqu9r878091 = ifdauporeuwqurghiuprewq89;
                for (int jupo7er90q7841rqpu = ifdauporeuwqurghiuprewq89 + 1; jupo7er90q7841rqpu < lenfdajipureqopufdag; jupo7er90q7841rqpu++) {
                    if (arrfdahiuryeqwfjdasopufdag[minValupoiurepqu9r878091] > arrfdahiuryeqwfjdasopufdag[jupo7er90q7841rqpu]) {
                        minValupoiurepqu9r878091 = jupo7er90q7841rqpu;
                    }
                }
                if (minValupoiurepqu9r878091 != ifdauporeuwqurghiuprewq89) {
                    int tmpure7wq9047312yrqewt = arrfdahiuryeqwfjdasopufdag[ifdauporeuwqurghiuprewq89];
                    arrfdahiuryeqwfjdasopufdag[ifdauporeuwqurghiuprewq89] = arrfdahiuryeqwfjdasopufdag[minValupoiurepqu9r878091];
                    arrfdahiuryeqwfjdasopufdag[minValupoiurepqu9r878091] = tmpure7wq9047312yrqewt;
                }
            }
            ViewHold hold;
            if (convertView == null) {
                convertView = LayoutInflater.from(mContext).inflate(R.layout.listview_item_files_details, null);
                hold = new ViewHold();
                hold.im_type = (ImageView) convertView.findViewById(R.id.im_file_type);
                hold.tv_name = (TextView) convertView.findViewById(R.id.tv_filename);
                hold.tv_size = (TextView) convertView.findViewById(R.id.tv_filesize);
                hold.tv_path = (TextView) convertView.findViewById(R.id.tv_path);
                convertView.setTag(hold);
            } else {
                hold = (ViewHold) convertView.getTag();
            }
            File myFile = data.get(position);
            if (myFile.isFile()) {
                hold.im_type.setImageResource(R.drawable.nullfile_icon);
            } else {
                hold.im_type.setImageResource(R.drawable.big_file_folder);
            }
            hold.tv_name.setText(myFile.getName());
            hold.tv_size.setText(Formatter.formatFileSize(mContext, Util.getFileFolderTotalSize(myFile)));
            String path = myFile.getAbsolutePath();
            if (!TextUtils.isEmpty(path) && path.length() >= Util.getRootPath().length()) {
                hold.tv_path.setText(myFile.getAbsolutePath().substring(Util.getRootPath().length()));
            }
            return convertView;
        }
    }

    static class ViewHold {

        public ImageView im_type;

        TextView tv_name, tv_path, tv_size;
    }
}
